﻿function DateTimeValidatorEvaluateIsValid(val)
{
	// 获取控件值
	var controlValue = DateTimeValidatorGetValue(val.controltovalidate);
	if (typeof(controlValue) != "string" || controlValue == "")
		return true;
	
	var parseResult = Date.parse(controlValue.replace("-", "/"));
	if(parseResult)
		return true;
	return false;
}

// Get From System
function DateTimeValidatorGetValue(id) {
    var control;
    control = document.getElementById(id);
    if (typeof(control.value) == "string") {
        return control.value;
    }
    return DateTimeValidatorGetValueRecursive(control);
}

function DateTimeValidatorGetValueRecursive(control)
{
    if (typeof(control.value) == "string" && (control.type != "radio" || control.checked == true)) {
        return control.value;
    }
    var i, val;
    for (i = 0; i<control.childNodes.length; i++) {
        val = DateTimeValidatorGetValueRecursive(control.childNodes[i]);
        if (val != "") return val;
    }
    return "";
}

function DateTimeValidatorTrim(s) {
    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}